package shoot;

import java.awt.image.BufferedImage;
import java.util.Random;

/**
 * 小蜜蜂
 */
public class Bee extends FlyingObject implements Award{
    private int yspeed;
    private int xspeed;
    private int awardType;//奖励类型

    public static BufferedImage[] images=new BufferedImage[4];
    static {
    	for (int i = 0; i < images.length; i++) {
			images[i]=loadImage("bee"+i+".png");
		}
    }
    
    public Bee(){
        super(60,50);
        xspeed=2;
        yspeed=1;
        Random random=new Random();
        awardType=random.nextInt(2);
    }

    int index=0;
    @Override
    public BufferedImage getImage() {
    	// TODO Auto-generated method stub
    	if (isLife()) {
			return images[0];
		}else if (isRemove()) {
			if (index==images.length) {
				state=DIE;
			}
			return images[index++];
		}
    	return null;
    }

    @Override
    public void step() {
    	// TODO Auto-generated method stub
    	this.y+=yspeed;
    	this.x+=xspeed;
    	if (x<=0 || x>=World.WIDTH-this.width ) {
    		xspeed=-xspeed;
		}
    }
    
    @Override
    public int getAwardType() {
    	// TODO Auto-generated method stub
    	return awardType;
    }



}
